<?php require ('common.inc.php'); ?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />
    <script type="text/javascript" src="public/home/js/jquery.min.js"></script>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="public/home/js/html5.js"></script>
    <![endif]-->
    <script type="text/javascript" src="public/home/js/jquery.cycle.all.min.js"></script>
    <link href="public/home/css/H-ui.reset.css" rel="stylesheet" type="text/css" />
    <link href="public/home/css/style.css" rel="stylesheet" type="text/css" /><!--自己的样式-->
    <link href="public/home/css/plugs.css" rel="stylesheet" type="text/css" /><!--自己的样式-->
</head>
<body class="bg-df" style="position: relative;">

<div class="chpass">
<?php
    //手机验证成功则修改登录密码
    if($_POST["action"]=="chpwd"){
        $phone = checkstr(trim($_POST['rgmobile']));
        $pcode = checkstr($_POST['pcode']);
        $pwd=createRandomStr(2);
		// $mbq=checkstr($_POST['mbq']);
		// $mba=checkstr(trim($_POST['rgmba']));
		// if(!isset($mbq)){
		// 	echo '没有选择密保问题，请返回！';
		// 	exit;
		// }

        if(empty($pcode)){
            msg_b('验证码不能为空，请返回！');
        }

        $mobile_code = $_SESSION['mobile_code'];
        if($mobile_code!=$pcode){
            msg_b('验证码错误，请返回！');
        }

		if($_SESSION['mobile']!=$phone){
			msg_b('手机号码不对应，请返回');
		}

		$db->query("select * from ld_user_info where phone = ".$phone,2);
		$user_info = $db->rs;
		if(empty($user_info)){
			msg_b('手机号码未注册，请返回！');
		}

		$user = $member->getuvinfo($user_info['id']);
		if($user['is_freezed'] == 1){
			msg_b('您的账号已被冻结，请返回！');
		}
		// if($user_info['mbq'] != $mbq || $user_info['rgmba']!=$mba){
		// 	echo '密保验证错误，请返回！';
		// 	exit;
		// }

        $rpwd=md5(md5($pwd.SITEENCRYPT));

        $rs=$db->sitedbexec("update ld_user_info set rgpwd1='".$rpwd."' where phone='".$phone."'");

//         echo '您的密码已经重置为'.$pwd.'，请复制保存并尽快登录用户中心修改！';
// 		echo '<div class=""><a href="login.php">点击登录</a></div>';
		msg_l('您的密码已经重置为'.$pwd.'，请复制保存并尽快登录用户中心修改！','login.php');
    }
    //手机验证成功则修改登录密码
    if($_POST["action"]=="tradepwd"){
        $phone = checkstr(trim($_POST['rgmobile']));
        $pcode = checkstr($_POST['pcode']);
        $pwd=createRandomStr(2);
        // $mbq=checkstr($_POST['mbq']);
		// $mba=checkstr(trim($_POST['rgmba']));

		// if(!isset($mbq)){
		// 	echo '没有选择密保问题，请返回！';
		// 	exit;
		// }
        if(empty($pcode)){
            msg_b('验证码不能为空，请返回！');
        }

        $mobile_code = $_SESSION['mobile_code'];
        if($mobile_code!=$pcode){
            msg_b('验证码错误，请返回！');
        }

		if($_SESSION['mobile']!=$phone){
			msg_b('手机号码不对应，请返回！');
		}

		$db->query("select * from ld_user_info where phone = ".$phone,2);
		$user_info = $db->rs;
		if(empty($user_info)){
			msg_b('手机号码未注册，请返回！');
		}

		$user = $member->getuvinfo($user_info['id']);
		if($user['is_freezed'] == 1){
			msg_b('您的账号已被冻结，请返回！');
		}
		// if($user_info['mbq'] != $mbq || $user_info['rgmba']!=$mba){
		// 	echo '密保验证错误，请返回！';
		// 	exit;
		// }

        $rpwd=md5(md5($pwd.SITEENCRYPT));

        $rs=$db->sitedbexec("update ld_user_info set rgpwd2='".$rpwd."' where phone='".$phone."'");

//         echo '您的密码已经重置为'.$pwd.'，请复制保存并尽快登录用户中心修改！';
// 		echo '<div class=""><a href="login.php">点击登录</a></div>';
        msg_l('您的密码已经重置为'.$pwd.'，请复制保存并尽快登录用户中心修改！','login.php');
		exit;
    }
?>
</div>
<div class="bottom"><?php echo $GLOBALARR['sybottom']; ?></div>
</body>
</html>